package org.txazo.blog.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.txazo.blog.dao.MemberLoginInfoDao;
import org.txazo.blog.service.MemberLoginInfoService;
import org.txazo.blog.util.PasswdUtil;
import org.txazo.blog.vo.MemberLoginInfo;

/**
 * 用户模块业务逻辑实现
 * 
 * @author Tu XiaoZhou
 * @since 2013-08-10
 */
@Transactional
@Service("memberLoginInfoService")
public class MemberLoginInfoServiceImpl implements MemberLoginInfoService {

	@Autowired
	private MemberLoginInfoDao memberLoginInfoDao;

	@Override
	public boolean addMemberLoginInfo(MemberLoginInfo memberLoginInfo) {
		return memberLoginInfoDao.addMemberLoginInfo(memberLoginInfo);
	}

	@Override
	public boolean updateMemberLoginInfo(MemberLoginInfo memberLoginInfo) {
		return memberLoginInfoDao.updateMemberLoginInfo(memberLoginInfo);
	}

	@Override
	public MemberLoginInfo getMemberLoginInfo(String emailAccount) {
		return memberLoginInfoDao.getMemberLoginInfo(emailAccount);
	}

	@Override
	public boolean loginValidate(String emailAccount, String password) {
		MemberLoginInfo memberLoginInfo = memberLoginInfoDao
				.getMemberLoginInfo(emailAccount);
		return PasswdUtil
				.loginValidate(password, memberLoginInfo.getCipherText(),
						memberLoginInfo.getCipherKey());
	}

}
